package com.wiscamp.ninechapters.panels.application.assemblers;


import com.wiscamp.ninechapters.panels.application.command.CreateUserCommand;
import com.wiscamp.ninechapters.panels.application.command.UpdateUserCommand;
import com.wiscamp.ninechapters.panels.application.vo.SimpleUserVO;
import com.wiscamp.ninechapters.panels.application.vo.UserVO;
import com.wiscamp.ninechapters.panels.domain.entities.User;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring",
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        unmappedSourcePolicy = ReportingPolicy.IGNORE,
        nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
        nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
        imports = {AssemblyLoader.class})
public interface UserAssembler {
    UserAssembler Instance = Mappers.getMapper(UserAssembler.class);

    //@Mapping(target = "menus", expression = "java(AssemblyLoader.loadMenus(entity.getMenuIds()))")
    //@Mapping(target = "permissions", expression = "java(AssemblyLoader.loadPermissions(entity.getPermissionIds()))")
    @Mapping(target = "password", constant = "")
    UserVO toUserVO(User entity);

    SimpleUserVO toSimpleUserVO(User entity);

    User fromCreateCommand(CreateUserCommand createCommand);

    User fromUpdateCommand(UpdateUserCommand updateCommand);

    User mergeUpdateCommand(UpdateUserCommand updateCommand, @MappingTarget User entity);
}
